﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Hired
{
    public partial class deleteaccount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["delete"] == null)
            {
                Response.Redirect("home.aspx");
            }
            else if ((bool)Session["delete"])
            {
                if (User.IsInRole("company"))
                {
                    lblCompany.Visible = true;
                }
            }
        }

        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            if ((bool)Session["delete"])
            {
                // do some delete logic
                if (User.IsInRole("admin"))
                {
                    DBAdminStaffAccount.deleteAdminStaffAccountById(User.Identity.Name);
                }
                else if (User.IsInRole("company"))
                {
                    DBCompanyAccount.DeleteCompanyAccountById(User.Identity.Name);
                }
                else if (User.IsInRole("employer"))
                {
                    DBEmployerPassport.DeleteEmployerPassportById(User.Identity.Name);
                }
                else if (User.IsInRole("jobseeker"))
                {
                    DBJobseekerAccount.deleteJobseekerAccountById(User.Identity.Name);
                }

                FormsAuthentication.SignOut();
                Response.Redirect("home.aspx");
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("settings.aspx");
        }
    }
}